package com.heima.admin.controller.v1;

import com.heima.admin.service.AdminWmNewsService;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.NewsAuthDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author HNCheng
 * @version 1.0
 * @since 2023/8/2 14:39
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/news")
public class AdminWmNewsController {

    @Autowired
    private AdminWmNewsService adminWmNewsService;
    /**
     * 查询文章列表
     * @param newsAuthDto
     * @return
     */
    @PostMapping("/list_vo")
    public ResponseResult listVo(@RequestBody NewsAuthDto newsAuthDto){
        return adminWmNewsService.listVo(newsAuthDto);
    }

    /**
     * 查询文章详情
     * @param id
     * @return
     */
    @GetMapping("/one_vo/{id}")
    public ResponseResult wmNewsInfo(@PathVariable Integer id) {
        log.info("查询文章详情:{}",id);
        return adminWmNewsService.wmNewsInfo(id);
    }

    /**
     * 审核失败
     * @param newsAuthDto
     * @return
     */
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody NewsAuthDto newsAuthDto) {
        log.info("审核失败:{}", newsAuthDto);
        return adminWmNewsService.updateStatus(newsAuthDto);
    }
    /**
     * 审核成功
     * @param newsAuthDto
     * @return
     */
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody NewsAuthDto newsAuthDto) {
        log.info("审核成功:{}", newsAuthDto);
        return adminWmNewsService.updateStatus(newsAuthDto);
    }
}
